package com.zerak.excamplecalendarview;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import com.zerak.calendarviewlib.CalendarPickerView;
import com.zerak.calendarviewlib.CalendarPickerView.OnDateSelectedListener;
import com.zerak.calendarviewlib.CalendarPickerView.SelectionMode;

public class MainActivity extends Activity {

	CalendarPickerView calendar;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		final Calendar nextYear = Calendar.getInstance();
		nextYear.add(Calendar.DAY_OF_YEAR, 45);
		calendar = (CalendarPickerView) findViewById(R.id.calendar_view);
		calendar.init(new Date(System.currentTimeMillis()), nextYear.getTime()) //دائىرىسى
				.inMode(SelectionMode.SINGLE) //تاللاش شەكلى
				.withSelectedDate(new Date());//سۈكۈتتىكى تاللانما
		calendar.setOnDateSelectedListener(new OnDateSelectedListener() {

			@Override
			public void onDateUnselected(Date date) {

			}

			@Override
			public void onDateSelected(Date date) {

				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
				String dateString = formatter.format(date);
				System.out.println(dateString);
				Toast.makeText(MainActivity.this,
						"تاللىغان ۋاقىت:" + dateString, 3000).show();

			}
		});
	}
}
